import React, {Component} from 'react';
import {
  Dimensions,
  Image,
  ToastAndroid,
  StyleSheet,
  Text,
  View,
  ScrollView,
  TouchableOpacity,
  ActivityIndicator,
  TextInput,
  TouchableHighlight,
} from 'react-native';

import ModalDropdown from 'react-native-modal-dropdown';
import RNFileSelector from 'react-native-file-selector';
// import Picker from 'react-native-picker';
// import {Colors} from 'react-native/Libraries/NewAppScreen';
import {PermissionsAndroid} from 'react-native';
import {CommonImg, ProposalImg} from '../../images/index';
import Specify from '../SpecifyExecytiveDirector';
import {createProposal} from '../../api/index';
import {setToastMsg} from '../../actions/index';
import ImagePicker from 'react-native-image-crop-picker';

TextInput.defaultProps = Object.assign({}, TextInput.defaultProps, {
  defaultProps: false,
});
Text.defaultProps = Object.assign({}, Text.defaultProps, {
  allowFontScaling: false,
});
const {height, width} = Dimensions.get('window');
let title = '';
let docup = 1;
let ExecutorSta = 1;
let proposalTitle = '';
let proposalLimit = '';
let acceptorId = '';
let filePath = '';

export default class LaunchProposals extends Component {
  constructor(props) {
    super(props);
    this.state = {
      Title: '',
    };
  }
  render() {
    return (
      <ScrollView>
        <View
          style={{
            marginTop: height * 0.0149,
            width: width,
            height: height * 0.089,
            backgroundColor: '#FFFFFF',
          }}>
          <View
            style={{
              flexDirection: 'row',
              height: height * 0.0509,
              width: width,
            }}>
            <View
              style={{
                marginLeft: height * 0.0269,
                marginTop: height * 0.0134,
                width: height * 0.0044,
                height: height * 0.0322,
                borderWidth: height * 0.0044,
                borderColor: '#3399FF',
                backgroundColor: '#3399FF',
              }}
            />
            <View style={{width: width * 0.6666, flexDirection: 'column'}}>
              <Text
                style={{
                  marginLeft: height * 0.0074,
                  marginTop: height * 0.0119,
                  //fontFamily: 'MicrosoftYaHei',
                  fontSize: 15,
                  textAlign: 'left',
                  color: '#333333',
                }}>
                提案阶段
              </Text>
              <View
                style={{
                  marginLeft: height * 0.0074,
                  marginTop: height * 0.0029,
                  height: height * 0.0014,
                  width: width * 0.4,
                  borderWidth: (height * 7.496) / 10000,
                  borderColor: '#66CCFF',
                }}
              />
            </View>
          </View>

          <View
            style={{
              height: height * 0.0374,
              width: width,
              flexDirection: 'row',
            }}>
            <Text
              style={{
                marginLeft: height * 0.0269,
                //fontFamily: 'MicrosoftYaHei',
                fontSize: 11,
                textAlign: 'left',
                color: '#999999',
              }}>
              填写提案的
            </Text>
            <Text
              style={{
                //fontFamily: 'MicrosoftYaHei',
                fontSize: 11,
                textAlign: 'left',
                color: '#3399FF',
              }}>
              基本信息
            </Text>
          </View>
        </View>
        <TitleSta />
        <DocSta />
        <Executor
          ref={excutor => (this.excutor = excutor)}
          pressFunc={() =>
            this.props.navigation.navigate('Specify', {
              callback: url => {
                this.excutor.updateUrl(url);
              },
              uodateAcceptorId: id => {
                acceptorId = id;
              },
            })
          }
        />
        <TimeA
          pressFunc={() => this.props.navigation.navigate('HGBCSheQuZhiLi')}
        />
      </ScrollView>
    );
  }
}
class TitleSta extends Component {
  constructor(props) {
    super(props);
    this.state = {
      title: '', //标题
    };
  }
  updateText(text) {
    title = text;
    this.setState(text => {
      return {
        title: text,
      };
    });
  }
  /*async componentDidMount() {
        await this.createProposal();
    }*/
  render() {
    return (
      <View
        style={{
          backgroundColor: '#FFFFFF',
          height: height * 0.0449,
          width: width,
          flexDirection: 'column',
          justifyContent: 'center',
        }}>
        <View style={{flexDirection: 'row'}}>
          <TextInput
            style={{
              padding: 0,
              paddingVertical: 0,
              marginLeft: height * 0.0269,
              marginTop: height * 0.001,
              //fontFamily: 'MicrosoftYaHei',
              fontSize: 10,
              textAlign: 'left',
              justifyContent: 'center',
              color: '#999999',
            }}
            onChangeText={text => {
              this.updateText(text);
            }}
            placeholder="输入标题"
          />
          {this.state.title !== '' ? null : (
            <Text
              style={{
                marginLeft: height * 0.2098,
                marginTop: height * 0.013,
                //fontFamily: 'MicrosoftYaHei',
                fontSize: 9,
                textAlign: 'left',
                justifyContent: 'center',
                color: '#CCCCCC',
              }}>
              （至多20字）
            </Text>
          )}
        </View>
        <View
          style={{
            marginLeft: height * 0.0269,
            height: height * 0.0007,
            width: width * 0.72,
            borderWidth: height * 0.0007,
            borderColor: '#CCCCCC',
            backgroundColor: '#CCCCCC',
          }}
        />
      </View>
    );
  }
}
class DocSta extends Component {
  constructor(props) {
    super(props);
    this.state = {
      proposalUrl: '', //文档
      // TODO 这里的文档url需要改
      docup: 1,
      fileName: '',
    };
  }

  selectFile() {
    console.log('begin select files');
    RNFileSelector.Show({
      title: 'Select File',
      onDone: path => {
        console.log('file selected: ' + path);
        //this.setState({
        filePath = 'file://' + path;
        //});
        this.setState({
          fileName: filePath.substr(filePath.lastIndexOf('/') + 1),
        });
        proposalTitle = this.state.fileName;
        //alert("成功了！"+ docup);
        docup = 0;
        this.setState({
          docup: 0,
        });
        //alert("我好了"+this.state.docup);
      },
      onCancel: () => {
        console.log('cancelled');
      },
    });
  }
  updateExecuteDocURL() {
    // if (this.state.docup === 1) {
    //   this.setState({
    //     docup: 0,
    //   });
    //   docup = 0;
    // }
    this.selectFile();
  }

  render() {
    if (this.state.docup === 1) {
      return (
        <ScrollView>
          <View style={{backgroundColor: '#FFFFFF', width: width}}>
            <View
              style={{
                backgroundColor: '#FFFFFF',
                marginTop: height * 0.0044,
                marginLeft: height * 0.0269,
                height: height * 0.1319,
                width: width * 0.72,
                borderWidth: height * 0.0014,
                borderColor: '#3399FF',
              }}>
              <View
                style={{
                  height: height * 0.0974,
                  width: width * 0.72,
                  flexDirection: 'row',
                }}>
                <Image
                  style={{
                    height: height * 0.0674,
                    width: height * 0.0569,
                    resizeMode: 'stretch',
                    marginLeft: height * 0.0254,
                    marginTop: height * 0.0134,
                  }}
                  source={ProposalImg.File}
                />
                <TouchableOpacity
                  onPress={() => {
                    this.updateExecuteDocURL();
                  }}>
                  <View style={{width: width * 0.56, height: height * 0.0674}}>
                    <Text
                      style={{
                        marginLeft: height * 0.0299,
                        marginTop: height * 0.0224,
                        //fontFamily: 'MicrosoftYaHei',
                        fontSize: 11,
                        textAlign: 'left',
                        color: '#666666',
                      }}>
                      还未上传提案文档，点击此处上传！注：提案文档请按照模板填写。
                    </Text>
                  </View>
                </TouchableOpacity>
              </View>
              <View
                style={{
                  height: height * 0.0224,
                  width: width * 0.72,
                  flexDirection: 'row',
                  justifyContent: 'center',
                  alignItems: 'center',
                }}>
                <Text
                  style={{
                    marginLeft: width * 0.0153,
                    //fontFamily: 'MicrosoftYaHei',
                    fontSize: 9,
                    color: '#999999',
                    justifyContent: 'center',
                    textAlign: 'center',
                  }}>
                  文档未上传
                </Text>
                <Text
                  style={{
                    marginLeft: height * 0.1204,
                    marginTop: 2,
                    //fontFamily: 'MicrosoftYaHei',
                    fontSize: 9,
                    textAlign: 'left',
                    justifyContent: 'center',
                    color: '#3399FF',
                  }}>
                  (模板可在提案规则页下载)
                </Text>
              </View>
            </View>
          </View>
        </ScrollView>
      );
    } else {
      return (
        <ScrollView>
          <View
            style={{
              marginTop: height * 0.0044,
              marginLeft: height * 0.0269,
              height: height * 0.1319,
              width: width * 0.72,
              borderWidth: height * 0.0014,
              borderColor: '#3399FF',
            }}>
            <View
              style={{
                height: height * 0.0974,
                width: width * 0.72,
                flexDirection: 'row',
              }}>
              <Image
                style={{
                  height: height * 0.0674,
                  width: height * 0.0569,
                  resizeMode: 'stretch',
                  marginLeft: height * 0.0254,
                  marginTop: height * 0.0134,
                }}
                source={ProposalImg.File}
              />
              <View style={{width: width * 0.56, height: height * 0.0674}}>
                <Text
                  style={{
                    marginLeft: height * 0.0299,
                    marginTop: height * 0.0224,
                    //fontFamily: 'MicrosoftYaHei',
                    fontSize: 11,
                    textAlign: 'left',
                    color: '#666666',
                  }}>
                  {this.state.fileName}
                </Text>
              </View>
            </View>
            <View
              style={{
                height: height * 0.0224,
                width: width * 0.72,
                flexDirection: 'row',
                justifyContent: 'center',
                alignItems: 'center',
              }}>
              <Text
                style={{
                  //fontFamily: 'MicrosoftYaHei',
                  fontSize: 9,
                  textAlign: 'left',
                  color: '#3399FF',
                }}>
                文档上传成功
              </Text>
              <TouchableOpacity
                onPress={() => {
                  this.updateExecuteDocURL();
                }}>
                <Text
                  style={{
                    marginLeft: height * 0.1574,
                    marginTop: height * 0.0029,
                    //fontFamily: 'MicrosoftYaHei',
                    fontSize: 9,
                    textAlign: 'left',
                    color: '#3399FF',
                  }}>
                  点击可重新上传文件
                </Text>
              </TouchableOpacity>
            </View>
          </View>
        </ScrollView>
      );
    }
  }
}
//TODO 如果是从网上拉下来的应该没啥改动，但我拉的时候出现了合并问题，最好检查一下一样不一样
class Executor extends Component {
  constructor(props) {
    super(props);
    this.state = {
      ExecutorSta: 1,
      portraitkey: '',
    };
  }
  updateExe() {
    //this.jump();
    if (this.state.ExecutorSta === 1) {
      ExecutorSta = 0;
      this.setState(() => {
        return {
          ExecutorSta: 0,
        };
      });
    }
  }
  updateUrl(url) {
    this.setState({
      portraitkey: url,
    });
  }
  async ProposalImage() {
    // let portraitkey = '';
    // await getData('portraitkey', function(text) {
    //   portraitkey = text;
    // });
  }
  render() {
    const {pressFunc} = this.props;
    if (this.state.ExecutorSta === 1) {
      return (
        <ScrollView>
          <View
            style={{
              backgroundColor: '#FFFFFF',
              height: height * 0.065,
              width: width,
            }}>
            <View
              style={{
                marginLeft: height * 0.0269,
                marginTop: height * 0.02,
                flexDirection: 'row',
              }}>
              <Text
                style={{
                  marginTop: height * 0.0108,
                  //fontFamily: 'MicrosoftYaHei',
                  fontSize: 12,
                  textAlign: 'left',
                  color: '#0099FF',
                }}>
                执行人：
              </Text>
              <Text
                style={{
                  marginTop: height * 0.0108,
                  //fontFamily: 'MicrosoftYaHei',
                  fontSize: 12,
                  textAlign: 'left',
                  color: '#999999',
                }}>
                未指名
              </Text>
              <TouchableOpacity
                onPress={() => {
                  this.updateExe();
                  pressFunc();
                  this.ProposalImage();
                }}>
                <View
                  style={{
                    marginLeft: width * 0.0533,
                    marginTop: height * 0.0089,
                    height: height * 0.0329,
                    width: width * 0.2666,
                    borderWidth: height * 0.0014,
                    borderColor: '#6699FF',
                    borderRadius: 2,
                    backgroundColor: '#6699FF',
                    justifyContent: 'center',
                    alignItems: 'center',
                  }}>
                  <Text
                    style={{
                      //fontFamily: 'MicrosoftYaHei',
                      fontSize: 12,
                      textAlign: 'left',
                      color: '#FFFFFF',
                    }}>
                    指名执行董事
                  </Text>
                </View>
              </TouchableOpacity>
            </View>
          </View>
        </ScrollView>
      );
    } else {
      return (
        <ScrollView>
          <View
            style={{
              backgroundColor: '#FFFFFF',
              height: height * 0.065,
              width: width,
            }}>
            <View
              style={{
                marginLeft: height * 0.0269,
                marginTop: height * 0.02,
                flexDirection: 'row',
              }}>
              <Text
                style={{
                  marginTop: height * 0.0108,
                  //fontFamily: 'MicrosoftYaHei',
                  fontSize: 12,
                  textAlign: 'left',
                  color: '#0099FF',
                }}>
                执行人：
              </Text>
              <View
                style={{
                  marginLeft: height * 0.0044,
                  flexDirection: 'row',
                  flexWrap: 'wrap',
                }}>
                <TouchableOpacity>
                  <View
                    style={{
                      marginTop: height * 0.003,
                      marginRight: width * 0.013,
                      backgroundColor: '#CCCCCC',
                      width: height * 0.042,
                      height: height * 0.042,
                      borderRadius: height * 0.021,
                    }}>
                    <Image
                      style={{
                        resizeMode: 'cover',
                        width: height * 0.042,
                        height: height * 0.042,
                        borderRadius: height * 0.042,
                      }}
                      source={{uri: this.state.portraitkey}}
                    />
                  </View>
                </TouchableOpacity>
              </View>
              <TouchableOpacity
                onPress={() => {
                  this.updateExe();
                  pressFunc();
                }}>
                <View
                  style={{
                    marginLeft: width * 0.0533,
                    marginTop: height * 0.0089,
                    height: height * 0.0329,
                    width: width * 0.2666,
                    borderWidth: height * 0.0014,
                    borderColor: '#6699FF',
                    borderRadius: 2,
                    backgroundColor: '#FFFFFF',
                    alignItems: 'center',
                    justifyContent: 'center',
                  }}>
                  <Text
                    style={{
                      //fontFamily: 'MicrosoftYaHei',
                      fontSize: 12,
                      textAlign: 'left',
                      color: '#3399FF',
                    }}>
                    更换执行董事
                  </Text>
                </View>
              </TouchableOpacity>
            </View>
          </View>
        </ScrollView>
      );
    }
  }
}
class Border1 extends Component {
  render() {
    return (
      <View
        style={{
          marginTop: height * 0.0299,
          marginLeft: width * 0.048,
          height: height * 0.0299,
          flexDirection: 'row',
        }}>
        <View
          style={{
            marginTop: height * 0.0044,
            height: height * 0.0179,
            width: height * 0.0179,
            borderWidth: 1,
            borderColor: '#666666',
            borderRadius: 2,
          }}
        />
        <Text
          style={{
            marginLeft: width * 0.0133,
            marginTop: height * 0.0029,
            //fontFamily: 'MicrosoftYaHei',
            fontSize: 12,
            textAlign: 'left',
            color: '#666666',
          }}>
          我同意以上条例。
        </Text>
      </View>
    );
  }
}
class Border2 extends Component {
  render() {
    return (
      <View
        style={{
          marginTop: height * 0.0299,
          marginLeft: width * 0.048,
          height: height * 0.0299,
          flexDirection: 'row',
        }}>
        <View
          style={{
            marginTop: height * 0.0044,
            height: height * 0.0179,
            width: height * 0.0179,
            borderWidth: 1,
            borderColor: '#666666',
            borderRadius: 2,
            justifyContent: 'center',
            alignItems: 'center',
          }}>
          <View
            style={{
              height: height * 0.0097,
              width: height * 0.0097,
              borderWidth: 1,
              borderColor: '#3399FF',
              backgroundColor: '#3399FF',
            }}
          />
        </View>
        <Text
          style={{
            marginLeft: width * 0.0133,
            marginTop: height * 0.0029,
            //fontFamily: 'MicrosoftYaHei',
            fontSize: 12,
            textAlign: 'left',
            color: '#666666',
          }}>
          我同意以上条例。
        </Text>
      </View>
    );
  }
}
class Button1 extends Component {
  render() {
    return (
      <View
        style={{
          alignItems: 'center',
          justifyContent: 'center',
          backgroundColor: '#F3F7FA',
        }}>
        <View
          style={{
            height: height * 0.0524,
            width: width * 0.9013,
            alignItems: 'center',
            justifyContent: 'center',
            backgroundColor: '#CCCCCC',
            borderRadius: 5,
          }}>
          <Text
            style={{
              //fontFamily: 'MicrosoftYaHei',
              fontSize: 14,
              textAlign: 'left',
              color: '#FFFFFF',
            }}>
            提 交
          </Text>
        </View>
      </View>
    );
  }
}
class Button2 extends Component {
  render() {
    return (
      <View
        style={{
          alignItems: 'center',
          justifyContent: 'center',
          backgroundColor: '#F3F7FA',
        }}>
        <View
          style={{
            height: height * 0.0524,
            width: width * 0.9013,
            alignItems: 'center',
            justifyContent: 'center',
            backgroundColor: '#3399FF',
            borderRadius: 5,
          }}>
          <Text
            style={{
              //fontFamily: 'MicrosoftYaHei',
              fontSize: 14,
              textAlign: 'left',
              color: '#FFFFFF',
            }}>
            提 交
          </Text>
        </View>
      </View>
    );
  }
}

export class CourseDetails extends Component {
  constructor(props) {
    super(props);
    this.state = {
      dropDown_box: false, // 下拉菜单 显隐状态
      dropDown_box_Text: '三个月', // 传值
      proposalLimit: 3,
    };
  }
  render() {
    return (
      <View
        style={{
          justifyContent: 'center',
          alignItems: 'center',
          marginLeft: width * 0.0533,
          marginTop: height * 0.0089,
        }}>
        <TouchableOpacity
          style={{
            height: height * 0.0329,
            width: width * 0.2696,
            borderWidth: 1,
            borderColor: '#CCCCCC',
            borderRadius: 2,
            backgroundColor: '#FFFFFF',
            flexDirection: 'column',
          }}
          onPress={() => {
            this.dropDown_box_Toggle();
          }}>
          <Text style={{justifyContent: 'center', textAlign: 'center'}}>
            {this.state.dropDown_box_Text}
          </Text>
        </TouchableOpacity>
        {this.dropDown_box_Fun()}
      </View>
    );
  }

  // 下拉菜单 显隐状态
  dropDown_box_Toggle() {
    this.setState({
      dropDown_box: !this.state.dropDown_box,
    });
  }
  dropDown_box_Fun() {
    if (this.state.dropDown_box === true) {
      return (
        <View
          style={{
            height: height * 0.1199,
            width: width * 0.2696,
            borderRadius: 4,
            borderWidth: 1,
            borderColor: '#CCCCCC',
            justifyContent: 'center',
            alignItems: 'center',
          }}>
          <TouchableOpacity
            onPress={() => {
              proposalLimit = 3;
              this.setState({
                dropDown_box_Text: '三个月',
                dropDown_box: false,
                proposalLimit: 3,
              });
            }}>
            <Text style={{justifyContent: 'center', textAlign: 'center'}}>
              三个月
            </Text>
          </TouchableOpacity>
          <View
            style={{
              height: (height * 7.496) / 10000,
              width: width * 0.2133,
              borderWidth: (height * 7.496) / 10000,
              borderColor: '#CCCCCC',
              justifyContent: 'center',
            }}
          />
          <TouchableOpacity
            onPress={() => {
              proposalLimit = 6;
              this.setState({
                dropDown_box_Text: '六个月',
                dropDown_box: false,
                proposalLimit: 6,
              });
            }}>
            <Text style={{justifyContent: 'center', textAlign: 'center'}}>
              六个月
            </Text>
          </TouchableOpacity>
          <View
            style={{
              height: (height * 7.496) / 10000,
              width: width * 0.2133,
              borderWidth: (height * 7.496) / 10000,
              borderColor: '#CCCCCC',
              justifyContent: 'center',
            }}
          />
          <TouchableOpacity
            onPress={() => {
              proposalLimit = 9;
              this.setState({
                dropDown_box_Text: '九个月',
                dropDown_box: false,
                proposalLimit: 9,
              });
            }}>
            <Text style={{justifyContent: 'center', textAlign: 'center'}}>
              九个月
            </Text>
          </TouchableOpacity>
          <View
            style={{
              height: (height * 7.496) / 10000,
              width: width * 0.2133,
              borderWidth: (height * 7.496) / 10000,
              borderColor: '#CCCCCC',
              justifyContent: 'center',
            }}
          />
          <TouchableOpacity
            onPress={() => {
              proposalLimit = 12;
              this.setState({
                dropDown_box_Text: '一年',
                dropDown_box: false,
                proposalLimit: 12,
              });
            }}>
            <Text style={{justifyContent: 'center', textAlign: 'center'}}>
              一年
            </Text>
          </TouchableOpacity>
        </View>
      );
    }
  }
}

export class DownSelect extends Component {
  constructor(props) {
    super(props);
    this.state = {
      isshow: false,
    };
  }
  render() {
    return (
      <View style={styles.Container}>
        <ModalDropdown
          style={styles.dropdown}
          //下拉样式
          dropdownStyle={styles.dropdown_dropdown}
          //文字样式
          textStyle={styles.dropdown_text}
          //每一行
          renderRow={this._dropdown_renderRow.bind(this)}
          onDropdownWillShow={this._dropdown_willShow.bind(this)}
          onDropdownWillHide={this._dropdown_willHide.bind(this)}
          defaultValue={'2018年'}
          options={['2018年', '2019年', '2020年']}
        />

        <Image
          source={this.state.isshow ? ProposalImg.Down : CommonImg.Arrow}
          style={styles.imgIcon}
        />
      </View>
    );
  }
  _dropdown_renderRow(rowData, rowID, highlighted) {
    let evenRow = rowID % 2;
    return (
      <TouchableHighlight underlayColor="cornflowerblue">
        <View
          style={[
            styles.dropdown_row,
            highlighted && {backgroundColor: '#a5d2f2'},
          ]}>
          <Text
            style={[styles.dropdown_row_text, highlighted && {color: 'white'}]}>
            {`${rowData}`}
          </Text>
        </View>
      </TouchableHighlight>
    );
  }
  /**
   * 显示前
   */

  _dropdown_willShow() {
    this.setState({
      isshow: true,
    });
  }
  /**
   * 显示后
   */
  _dropdown_willHide() {
    this.setState({
      isshow: false,
    });
  }
}
const styles = StyleSheet.create({
  Container: {
    marginLeft: width * 0.0533,
    marginTop: height * 0.0089,
    height: height * 0.0329,
    width: width * 0.2666,
    borderWidth: height * 0.0014,
    borderColor: '#6699FF',
    borderRadius: 2,
    backgroundColor: '#6699FF',
    justifyContent: 'center',
    alignItems: 'center',
  },
  dropdown: {
    marginLeft: width * 0.0533,
    marginTop: height * 0.0089,
    height: height * 0.0329,
    width: width * 0.2666,
    borderWidth: height * 0.0014,
    borderColor: '#CCCCCC',
    borderRadius: 2,
    backgroundColor: '#FFFFFF',
    justifyContent: 'center',
    alignItems: 'center',
  },
  dropdown_text: {
    fontSize: 14,
    color: '#a5d2f2',
  },
  imgIcon: {
    width: 15,
    marginTop: 68,
    height: 15,
    position: 'absolute',
    left: 55,
  },
  dropdown_dropdown: {
    width: 60,
    height: 78,
  },
  dropdown_row: {
    flexDirection: 'row',
    height: 25,
    width: 60,
    alignItems: 'center',
  },

  dropdown_row_text: {
    marginHorizontal: 2,
    fontSize: 10,
    color: '#515a6e',
    textAlignVertical: 'center',
  },
});

class TimeA extends Component {
  constructor(props) {
    super(props);
    this.state = {
      language: 1,
      Bor: 1,
      But: 1,
    };
  }
  updateBut() {
    if (this.state.But === 1) {
      this.setState({But: 0});
    } else {
      this.setState({But: 1});
    }
  }
  updateBorder() {
    if (this.state.Bor === 1) {
      this.setState({Bor: 0});
    } else {
      this.setState({Bor: 1});
    }
  }
  async ProposalUp() {
    let parameters = {
      title: title,
      proposalTitle: proposalTitle,
      proposalLimit: proposalLimit,
      acceptorId: acceptorId,
      files: {
        uri: filePath,
        type: 'multipart/form-data',
        name: proposalTitle,
      },
    };
    const result = await createProposal(parameters);
    this.setState({
      result: result,
    });
    setToastMsg('上传成功');

    this.props.pressFunc();
  }
  render() {
    const {pressFunc} = this.props;
    if (1 === 1) {
      return (
        <View>
          <View
            style={{
              height: height * 0.32,
              width: width,
              backgroundColor: '#FFFFFF',
            }}>
            <View
              style={{
                marginTop: height * 0.0179,
                marginLeft: width * 0.048,
                height: height * 0.0374,
                width: width * 0.904,
                flexDirection: 'row',
              }}>
              <Text
                style={{
                  marginTop: height * 0.0074,
                  //fontFamily: 'MicrosoftYaHei',
                  fontSize: 12,
                  textAlign: 'left',
                  color: '#0099FF',
                  justifyContent: 'center',
                }}>
                提案验收期限：
              </Text>
              <CourseDetails />
            </View>
            <View
              style={{
                marginTop: height * 0.0749,
                marginLeft: width * 0.048,
                height: height * 0.0824,
                width: width * 0.904,
                flexDirection: 'column',
              }}>
              <Text
                style={{
                  //fontFamily: 'MicrosoftYaHei',
                  fontSize: 12,
                  textAlign: 'left',
                  color: '#FF6666',
                }}>
                注意：
              </Text>
              <Text
                style={{
                  //fontFamily: 'MicrosoftYaHei',
                  fontSize: 12,
                  textAlign: 'left',
                  color: '#666666',
                }}>
                若提案中途被否决或是规定时间内未能验收完成，相关人员需要承担相应责任。
              </Text>
            </View>
            <View
              style={{
                marginTop: height * 0.0059,
                marginLeft: width * 0.048,
                height: height * 0.0224,
                width: width * 0.904,
              }}>
              {/*<TouchableOpacity>*/}
              {/*  <Text*/}
              {/*    style={{*/}
              {/*      marginLeft: width * 0.5466,*/}
              {/*      fontFamily: 'MicrosoftYaHei',*/}
              {/*      fontSize: 11,*/}
              {/*      textAlign: 'left',*/}
              {/*      color: '#3399FF',*/}
              {/*    }}>*/}
              {/*    (点我前去了解提案规则)*/}
              {/*  </Text>*/}
              {/*</TouchableOpacity>*/}
              <View style={{height: height * 0.0224, width: width}} />
            </View>
            <TouchableOpacity
              onPress={() => {
                this.updateBorder();
              }}>
              {this.state.Bor === 1 ? <Border1 /> : <Border2 />}
            </TouchableOpacity>
          </View>
          <View
            style={{
              height: height * 0.1334,
              width: width,
              backgroundColor: '#F3F7FA',
            }}
          />
          <TouchableOpacity
            onPress={() => {
              if (
                this.state.Bor === 0 &&
                docup === 0 &&
                ExecutorSta === 0 &&
                title !== ''
              ) {
                this.ProposalUp();
              }
            }}>
            {this.state.Bor === 0 &&
            docup === 0 &&
            ExecutorSta === 0 &&
            title !== '' ? (
              <Button2 />
            ) : (
              <Button1 />
            )}
          </TouchableOpacity>
          <View
            style={{
              height: height * 0.0989,
              width: width,
              backgroundColor: '#F3F7FA',
            }}
          />
        </View>
      );
    }
  }
}
